<html>
<heand>

	<div class="index">

	<script language="JavaScript">
	function selectBoxP()
	{
		$selectBox=document.getElementById("selectBoxPortfolio");
		$selectedValue=$selectBox.options[$selectBox.selectedIndex].value;
	}

	function selectBoxF()
	{
		$selectBox=document.getElementById("selectBoxFund");
		$selectedValue=$selectBox.options[$selectBox.selectedIndex].value;
	}

	function display()
	{
		document.getElementById('modifyForm').style.display='none';
		document.getElementById('modifyFund').style.display='none';
		document.getElementById('addFund').style.display='none';
		document.getElementById('addRpm').style.display='none';
		document.getElementById('modifyRpm').style.display='none';
		document.getElementById('addForm').style.display='';
	}

	function display2()
	{
		document.getElementById('addForm').style.display='none';
		document.getElementById('modifyFund').style.display='none';
		document.getElementById('addFund').style.display='none';
		document.getElementById('addRpm').style.display='none';
		document.getElementById('modifyRpm').style.display='none';
		document.getElementById('modifyForm').style.display='';
	}

	function display3()
	{
		document.getElementById('addForm').style.display='none';
		document.getElementById('modifyForm').style.display='none';
		document.getElementById('modifyFund').style.display='none';
		document.getElementById('addRpm').style.display='none';
		document.getElementById('modifyRpm').style.display='none';
		document.getElementById('addFund').style.display='';
	}

	function display4()
	{
		document.getElementById('addForm').style.display='none';
		document.getElementById('modifyForm').style.display='none';
		document.getElementById('addFund').style.display='none';
		document.getElementById('addRpm').style.display='none';
		document.getElementById('modifyRpm').style.display='none';
		document.getElementById('modifyFund').style.display='';
	}
	function display5()
	{
		document.getElementById('addForm').style.display='none';
		document.getElementById('modifyForm').style.display='none';
		document.getElementById('addFund').style.display='none';
		document.getElementById('modifyFund').style.display='none';
		document.getElementById('addRpm').style.display='';
		document.getElementById('modifyRpm').style.display='none';
	}
	function display6()
	{
		document.getElementById('addForm').style.display='none';
		document.getElementById('modifyForm').style.display='none';
		document.getElementById('addFund').style.display='none';
		document.getElementById('modifyFund').style.display='none';
		document.getElementById('addRpm').style.display='none';
		document.getElementById('modifyRpm').style.display='';
	}

	function reset()
	{
		document.getElementById('selectBoxPortfolio').selectedIndex=0;
		document.getElementById('selectBoxFund').selectedIndex=0;
		document.getElementById('datetext').value='';
		document.getElementById('fundtext').value='';
		document.getElementById('fundnametext').value='';
		document.getElementById('apircode').value='';
		document.getElementById('apircodenew').value='';
		document.getElementById('fweightingtext').value='';
		document.getElementById('indextext').value='';
		document.getElementById('iweightingtext').value='';
		document.getElementById('portfolionametext').value='';
		document.getElementById('datetext1').value='';
		document.getElementById('fundtext1').value='';
		document.getElementById('fweightingtext1').value='';
		document.getElementById('indextext1').value='';
		document.getElementById('iweightingtext1').value='';
	}

	function submitmodifyp()
	{
		if(document.getElementById('selectBoxPortfolio').selectedIndex==0)
		{
			alert("No portfolio has been selected");
		}
		else if (document.getElementById('fundtext').value=='' && document.getElementById('fweightingtext').value=='' && document.getElementById('indextext').value=='' && document.getElementById('iweightingtext').value=='')
		{
			alert("No changes have been made");
		}
		else
		{
			document.getElementById('modifyForm').submit();
		}
	}
	function submitaddp()
	{
		if(document.getElementById('portfolionametext').value!='' && document.getElementById('datetext1').value!='' && document.getElementById('fundtext1').value!='' && document.getElementById('fweightingtext1').value!='' && document.getElementById('indextext1').value!='' && document.getElementById('iweightingtext1').value!='')
		{
			document.getElementById('addForm').submit();
		}else
		{
			alert("Please fill in all the fields");
		}
	}
	function submitmodifyf()
	{
		if(document.getElementById('selectBoxFund').selectedIndex==0)
		{
			alert("No fund has been selected");
		}
		else if (document.getElementById('apircodenew').value=='')
		{
			alert("No changes have been made");
		}
		else
		{
			document.getElementById('modifyFund').submit();
		}
	}
	function submitaddf()
	{
		if(document.getElementById('fundnametext').value!='' && document.getElementById('apircode').value!='')
		{
			document.getElementById('addFund').submit();
		}
		else
		{
			alert("Please fill in all the fields");
		}
	}
	function submitaddrpm()
	{
		if(document.getElementById('rpmtext').value!='' && document.getElementById('datetextp').value!='' && document.getElementById('porttext').value!='' && document.getElementById('pweightingtextp').value!='' && document.getElementById('indextextp').value!='' && document.getElementById('iweightingtextp').value!='')
		{
			document.getElementById('addRpm').submit();
		}else
		{
			alert("Please fill in all the fields");
		}
	}
	function submitmodifyrpm()
	{
		if(document.getElementById('selectBoxRpm1').selectedIndex==0)
		{
			alert("No fund has been selected");
		}
		else if (document.getElementById('apircodenew').value=='')
		{
			alert("No changes have been made");
		}
		else
		{
			document.getElementById('modifyRpm').submit();
		}
	}
	</script>

</head>
<h2>Portfolio Management</h2>
<div class="btn-group" data-toggle="buttons">
  <button type="button" class="btn btn-default" data-toggle="button" id="addP" onclick="display();">Add Portfolio</button>
  <button type="button" class="btn btn-default" data-toggle="button" id="modifyP" onclick="display2();">Modify Portfolio</button>
  <button type="button" class="btn btn-default" data-toggle="button" id="addP" onclick="display5();">Add RPM</button>
  <button type="button" class="btn btn-default" data-toggle="button" id="modifyP" onclick="display6();">Modify RPM</button>
  <button type="button" class="btn btn-default" data-toggle="button" id="addF" onclick="display3();">Add Fund</button>
  <button type="button" class="btn btn-default" data-toggle="button" id="modifyF" onclick="display4();">Modify Fund</button>
</div>
<center>
<br>
<br><br>

<div id="container">
<form id="modifyForm" action="PortfolioManagement/modifyPortfolio" style="display:none;" method="post">
	<table >
		<tr>
			<td >Portfolio Name:</td>
			<td >
				<select id="selectBoxPortfolio" name="selectBoxPortfolio" onchange="selectBoxP();"> 
						<option value="none">Please select a portfolio</option>
					<?php
						for($n=0;$n<sizeof($portname);$n++)
						{?>
							<option><?php echo $portname[$n];?></option>
						<?php
						}
					?>
				</select>
			</td>
		</tr>
		<tr>
			<td>Date:</td>
			<td><input id="datetext" name="datetext" type='text'> (Use the Format: DD/MM/YYYY, eg. 10/01/2013)</td>
		</tr>
		<tr>
			<td>Funds List:</td>
			<td><input id="fundtext" name="fundtext" type="text"> (Insert funds using "," and without spaces, eg. fund 1,fund 2)</td>
		</tr>
		<tr>
		</tr>
		<tr>
			<td>Funds Weighting:</td>
			<td><input id="fweightingtext" name="fweightingtext" type="text"> (Insert funds weighting using "," and without spaces, eg. 0.5,0.5)</td>
		</tr>
		<tr>
			<td>Indices List:</td>
			<td><input id="indextext" name="indextext" type="text"> (Insert indices using "," and without spaces, eg. index 1,index 2)</td>
		</tr>
		<tr>
			<td>Indices Weighting:</td>
			<td><input id="iweightingtext" name="iweightingtext" type="text"> (Insert weighting using "," and without spaces, eg. 0.5,0.5)</td>
		</tr>
		<tr>
			<td></td>
			<td><button type="button" class="btn btn-default"  value="Reset" onclick="reset();">Reset</button><button type="button" class="btn btn-default" value="Submit" onclick="submitmodifyp();">Submit</button></td>
		</tr>
	</table>
</form>

<form id="addForm" action="PortfolioManagement/addPortfolio" style="display:none;" method="post">
	<table >
		<tr>
			<td >Portfolio Name:</td>
			<td ><input id="portfolionametext" name="portfolionametext" type="text"></td>
		</tr>
		<tr>
			<td>Starting Date:</td>
			<td><input id="datetext1" name="datetext1" type='text'> (Use the Format: DD/MM/YYYY, eg. 10/01/2013)</td>
		</tr>
		<tr>
			<td>Funds List:</td>
			<td><input id="fundtext1" name="fundtext1" type="text"> (Insert funds using "," and without spaces, eg. fund 1,fund 2)</td>
		</tr>
		<tr>
		</tr>
		<tr>
			<td>Funds Weighting:</td>
			<td><input id="fweightingtext1" name="fweightingtext1" type="text"> (Insert funds weighting using "," and without spaces, eg. 0.5,0.5)</td>
		</tr>
		<tr>
			<td>Indices List:</td>
			<td><input id="indextext1" name="indextext1" type="text"> (Insert indices using "," and without spaces, eg. index 1,index 2)</td>
		</tr>
		<tr>
			<td>Indices Weighting:</td>
			<td><input id="iweightingtext1" name="iweightingtext1" type="text"> (Insert weighting using "," and without spaces, eg. 0.5,0.5)</td>
		</tr>
		<tr>
			<td></td>
			<td><button type="button" class="btn btn-default" value="Reset" onclick="reset();">Reset</button><button type="button" class="btn btn-default" value="Submit" onclick="submitaddp();">Submit</button></td>
		</tr>
	</table>
</form>
<form id="addRpm" action="PortfolioManagement/addRpm" style="display:none;" method="post">
	<table >
		<tr>
			<td >RPM:</td>
			<td ><input id="rpmtext" name="rpmtext" type="text"></td>
		</tr>
		<tr>
			<td >Type:</td>
			<td ><select id="selectBoxRpm" name="selectBoxRpm" onchange="selectBoxR();"> 
					<option value="TAA">TAA</option>
					<option value="SAA">SAA</option>
				</select></td>
		</tr>
		<tr>
			<td>Starting Date:</td>
			<td><input id="datetextp" name="datetextp" type='text'> (Use the Format: DD/MM/YYYY, eg. 10/01/2013)</td>
		</tr>
		<tr>
			<td>Portfolios List:</td>
			<td><input id="porttext" name="porttext" type="text"> (Insert funds using "," and without spaces, eg. fund 1,fund 2)</td>
		</tr>
		<tr>
		</tr>
		<tr>
			<td>Portfolios Weighting:</td>
			<td><input id="pweightingtextp" name="pweightingtextp" type="text"> (Insert funds weighting using "," and without spaces, eg. 0.5,0.5)</td>
		</tr>
		<tr>
			<td>Indices List:</td>
			<td><input id="indextextp" name="indextextp" type="text"> (Insert indices using "," and without spaces, eg. index 1,index 2)</td>
		</tr>
		<tr>
			<td>Indices Weighting:</td>
			<td><input id="iweightingtextp" name="iweightingtextp" type="text"> (Insert weighting using "," and without spaces, eg. 0.5,0.5)</td>
		</tr>
		<tr>
			<td></td>
			<td><button type="button" class="btn btn-default" value="Reset" onclick="reset();">Reset</button><button type="button" class="btn btn-default" value="Submit" onclick="submitaddrpm();">Submit</button></td>
		</tr>
	</table>
</form>
<form id="modifyRpm" action="PortfolioManagement/modifyRpm" style="display:none;" method="post">
	<table >
		<tr>
			<td >RPM:</td>
			<td ><select id="selectBoxRpm1" name="selectBoxRpm1" onchange="selectBoxR1();"> 
					<option value="none">Please select a RPM</option>
					<?php 
						foreach($rpmname as $r)
						{
							?><option ><?php echo $r; ?></option><?php
						}
					?>
				</select></td>
		</tr>
		<tr>
			<td>Starting Date:</td>
			<td><input id="datetextp1" name="datetextp1" type='text'> (Use the Format: DD/MM/YYYY, eg. 10/01/2013)</td>
		</tr>
		<tr>
			<td>Portfolios List:</td>
			<td><input id="porttext2" name="porttext2" type="text"> (Insert funds using "," and without spaces, eg. fund 1,fund 2)</td>
		</tr>
		<tr>
		</tr>
		<tr>
			<td>Portfolios Weighting:</td>
			<td><input id="pweightingtextp1" name="pweightingtextp1" type="text"> (Insert funds weighting using "," and without spaces, eg. 0.5,0.5)</td>
		</tr>
		<tr>
			<td>Indices List:</td>
			<td><input id="indextextp1" name="indextextp1" type="text"> (Insert indices using "," and without spaces, eg. index 1,index 2)</td>
		</tr>
		<tr>
			<td>Indices Weighting:</td>
			<td><input id="iweightingtextp1" name="iweightingtextp1" type="text"> (Insert weighting using "," and without spaces, eg. 0.5,0.5)</td>
		</tr>
		<tr>
			<td></td>
			<td><button type="button" class="btn btn-default" value="Reset" onclick="reset();">Reset</button><button type="button" class="btn btn-default" value="Submit" onclick="submitmodifyrpm();">Submit</button></td>
		</tr>
	</table>
</form>


<form id="addFund" action="PortfolioManagement/addFund" style="display:none;" method="post">
	<table >
		<tr>
			<td >Fund Name:</td>
			<td ><input id="fundnametext" name="fundnametext" type="text"></td>
		</tr>
		<tr>
			<td>New APIR code:</td>
			<td><input id="apircode" name="apircode" type='text'></td>
		</tr>
		<tr>
			<td></td>
			<td><button type="button" class="btn btn-default" value="Reset" onclick="reset();">Reset</button><button type="button" class="btn btn-default" value="Submit" onclick="submitaddf();">Submit</button></td>
		</tr>
	</table>
</form>

<form id="modifyFund" action="PortfolioManagement/modifyFund" style="display:none;" method="post">
	<table >
		<tr>
			<td >Fund Name:</td>
			<td >
				<select id='selectBoxFund' name="selectBoxFund" onchange="selectBoxF();">
					<option value="none">Please select a fund</optioon>
					<?php
						for($m=0;$m<sizeof($fundname);$m++)
						{?>
							<option value='<?php echo $fundname[$m]; ?>'><?php echo $fundname[$m];?></option>
						<?php
						}
					?>
				</select>
			</td>
		</tr>
		<tr>
			<td>New APIR code:</td>
			<td><input id="apircodenew" name="apircodenew" type='text'></td>
		</tr>
		<tr>
			<td></td>
			<td><button type="button" class="btn btn-default" value="Reset" onclick="reset();">Reset</button><button type="button" class="btn btn-default" value="Submit" onclick="submitmodifyf();">Submit</button></td>
		</tr>
	</table>
</form>
</div>
</div>
</center>
</html>